<?php

namespace backend\models;

use Yii;
use yii\db\Exception;

class Teacher extends \common\models\Teacher
{
      private $name;
      private $sex;
      private $birthday;
      private $id_number;

    public function rules()
    {
        return array_merge([
            [[ 'GH'], 'match', 'pattern' => '/^\d+$/','message' => '该项填写内容应为纯数字'],  // 纯数字类字段
            [['RZSJ','LRSJ'], 'date', 'format' => 'php:Y-m-d', 'message' => '错误的日期格式，请重新修改'],
        ], parent::rules());
    }

    /**
     * @return mixed
     */
    public function getSex()
    {
        return $this->sex;
    }

    /**
     * @param mixed $sex
     */
    public function setSex($sex)
    {
        $this->sex = $sex;
    }

    /**
     * @return mixed
     */
    public function getBirthday()
    {
        return $this->birthday;
    }

    /**
     * @param mixed $birthday
     */
    public function setBirthday($birthday)
    {
        $this->birthday = $birthday;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param mixed $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return mixed
     */
    public function getIdNumber()
    {
        return $this->id_number;
    }

    /**
     * @param mixed $id_number
     */
    public function setIdNumber($id_number)
    {
        $this->id_number = $id_number;
    }

    // /**
    //  * 重载Teacher save方法，初始化Person类的属性
    //  * @param bool $runValidation
    //  * @param null $attributeNames
    //  * @return bool
    //  */
    // public function save($runValidation = true, $attributeNames = null)
    // {
    //     // $model=new Person();
    //     $model = Person::findOne($this->GRID);

    //     if(!isset($this->ID)){
    //         $model->name=$this->getName();
    //         $model->sex=$this->getSex();
    //         $model->birthday=$this->getBirthday();
    //         $model->id_number=$this->getIdNumber();
    //         $model->nationality='中国';
    //         $model->id_type='居民身份证';
    //         $model->ethnicity='汉族';
    //         $model->birthplace='北京';
    //         $model->native_place='北京';
    //         $model->address='北京';
    //         $model->mobile='12315';
    //         $model->create_time=date('Y-m-d');

    //         if($model->save()){
    //             $data=PersonSearch::find()->where(['id_number'=>$model->id_number])->one();
    //             $this->GRID=$data['id'];
    //         }else{
    //             throw new Exception('个人信息数据保存失败');
    //             return false;
    //         }
    //     }
        
    //     return parent::save($runValidation, $attributeNames);
    // }

}